<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>项目管理 - 学术科研管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f7fa;
            color: #333;
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }

        .header h1 {
            margin: 0;
            font-size: 24px;
        }

        .container {
            max-width: 1400px;
            margin: 20px auto;
            padding: 0 20px;
        }

        .toolbar {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            margin-bottom: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .search-box {
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .search-box input {
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
            width: 300px;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        .btn-primary {
            background: #007bff;
            color: white;
        }

        .btn-primary:hover {
            background: #0056b3;
        }

        .btn-success {
            background: #28a745;
            color: white;
        }

        .btn-success:hover {
            background: #1e7e34;
        }

        .btn-warning {
            background: #ffc107;
            color: #212529;
        }

        .btn-warning:hover {
            background: #e0a800;
        }

        .btn-danger {
            background: #dc3545;
            color: white;
        }

        .btn-danger:hover {
            background: #c82333;
        }

        .btn-sm {
            padding: 5px 10px;
            font-size: 12px;
        }

        .projects-table {
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            overflow: hidden;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }

        th {
            background: #f8f9fa;
            font-weight: 600;
            color: #495057;
        }

        tr:hover {
            background: #f8f9fa;
        }

        .status-badge {
            padding: 4px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
        }

        .status-pending {
            background: #fff3cd;
            color: #856404;
        }

        .status-in-progress {
            background: #d4edda;
            color: #155724;
        }

        .status-completed {
            background: #d1ecf1;
            color: #0c5460;
        }

        .status-on-hold {
            background: #f8d7da;
            color: #721c24;
        }

        .status-rejected {
            background: #f5c6cb;
            color: #721c24;
        }

        .actions {
            display: flex;
            gap: 5px;
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.5);
        }

        .modal-content {
            background-color: white;
            margin: 5% auto;
            padding: 0;
            border-radius: 8px;
            width: 80%;
            max-width: 600px;
            max-height: 90vh;
            overflow-y: auto;
        }

        .modal-header {
            padding: 20px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-header h3 {
            margin: 0;
        }

        .close {
            color: #aaa;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }

        .close:hover {
            color: #000;
        }

        .modal-body {
            padding: 20px;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
        }

        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
        }

        .form-group textarea {
            height: 80px;
            resize: vertical;
        }

        .form-row {
            display: flex;
            gap: 15px;
        }

        .form-row .form-group {
            flex: 1;
        }

        .modal-footer {
            padding: 20px;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        .loading {
            text-align: center;
            padding: 40px;
            color: #666;
        }

        .error {
            color: #dc3545;
            background: #f8d7da;
            padding: 10px;
            border-radius: 4px;
            margin-bottom: 15px;
        }

        .success {
            color: #155724;
            background: #d4edda;
            padding: 10px;
            border-radius: 4px;
            margin-bottom: 15px;
        }

        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: #666;
        }

        .empty-state h3 {
            margin-bottom: 10px;
            color: #999;
        }

        @media (max-width: 768px) {
            .container {
                padding: 0 10px;
            }
            
            .toolbar {
                flex-direction: column;
                gap: 15px;
                align-items: stretch;
            }
            
            .search-box {
                flex-direction: column;
            }
            
            .search-box input {
                width: 100%;
            }
            
            .modal-content {
                width: 95%;
                margin: 10px auto;
            }
            
            .form-row {
                flex-direction: column;
            }
            
            table {
                font-size: 12px;
            }
            
            .actions {
                flex-direction: column;
            }
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>📊 项目管理</h1>
    </div>

    <div class="container">
        <!-- 工具栏 -->
        <div class="toolbar">
            <div class="search-box">
                <input type="text" id="searchInput" placeholder="搜索项目名称、代码或负责人...">
                <button class="btn btn-primary" onclick="searchProjects()">🔍 搜索</button>
                <button class="btn btn-primary" onclick="loadProjects()">🔄 刷新</button>
            </div>
            <button class="btn btn-success" onclick="showCreateModal()">➕ 新建项目</button>
        </div>

        <!-- 项目列表 -->
        <div class="projects-table">
            <table>
                <thead>
                    <tr>
                        <th>项目名称</th>
                        <th>项目代码</th>
                        <th>负责人</th>
                        <th>项目状态</th>
                        <th>开始日期</th>
                        <th>结束日期</th>
                        <th>预算金额</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="projectsTableBody">
                    <tr>
                        <td colspan="8" class="loading">加载中...</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

    <!-- 创建/编辑项目模态框 -->
    <div id="projectModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3 id="modalTitle">新建项目</h3>
                <span class="close" onclick="closeModal()">&times;</span>
            </div>
            <div class="modal-body">
                <div id="modalError" class="error" style="display: none;"></div>
                <form id="projectForm">
                    <div class="form-group">
                        <label for="projectName">项目名称 *</label>
                        <input type="text" id="projectName" name="projectName" required>
                    </div>
                    
                    <div class="form-row">
                        <div class="form-group">
                            <label for="projectCode">项目代码</label>
                            <input type="text" id="projectCode" name="projectCode">
                        </div>
                        <div class="form-group">
                            <label for="status">项目状态 *</label>
                            <select id="status" name="status" required>
                                <option value="PENDING_APPROVAL">待审批</option>
                                <option value="IN_PROGRESS">进行中</option>
                                <option value="COMPLETED">已完成</option>
                                <option value="ON_HOLD">暂停中</option>
                                <option value="REJECTED">已拒绝</option>
                            </select>
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="form-group">
                            <label for="startDate">开始日期</label>
                            <input type="date" id="startDate" name="startDate">
                        </div>
                        <div class="form-group">
                            <label for="endDate">结束日期</label>
                            <input type="date" id="endDate" name="endDate">
                        </div>
                    </div>
                    
                    <div class="form-row">
                        <div class="form-group">
                            <label for="budgetAmount">预算金额</label>
                            <input type="number" id="budgetAmount" name="budgetAmount" step="0.01" min="0">
                        </div>
                        <div class="form-group">
                            <label for="principalInvestigatorId">项目负责人 *</label>
                            <select id="principalInvestigatorId" name="principalInvestigatorId" required>
                                <option value="">请选择负责人</option>
                            </select>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label for="description">项目描述</label>
                        <textarea id="description" name="description" placeholder="请输入项目描述..."></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="closeModal()">取消</button>
                <button type="button" class="btn btn-success" onclick="saveProject()">保存</button>
            </div>
        </div>
    </div>

    <script src="project-management.js"></script>
</body>
</html>
